package course.service.impl;

import course.dao.StuSubDao;
import course.dao.impl.StuSubDaoImpl;
import course.pojo.entity.StuSub;
import course.service.StuSubService;
import course.utils.JDBCUtil;

import java.sql.Connection;
import java.util.List;

/**
 * @author HLF
 * @date 2022/7/3 13:47
 */
public class StuSubServiceImpl implements StuSubService {
    private StuSubDao stuSubDao = new StuSubDaoImpl();
    
    @Override
    public int addStuSub(StuSub StuSub) {
        Connection connection = JDBCUtil.getConnection();
        int i = stuSubDao.addStuSub(StuSub, connection);
        JDBCUtil.closeConnection(connection);
        return i;
    }

    @Override
    public List<StuSub> getList() {
        Connection connection = JDBCUtil.getConnection();
        List<StuSub> list = stuSubDao.getList(connection);
        JDBCUtil.closeConnection(connection);
        return list;
    }

    @Override
    public List<StuSub> getBySid(Integer sid) {
        Connection connection = JDBCUtil.getConnection();
        List<StuSub> bySid = stuSubDao.getBySid(sid, connection);
        JDBCUtil.closeConnection(connection);
        return bySid;
    }

    @Override
    public List<StuSub> getBySuid(Integer suid) {
        Connection connection = JDBCUtil.getConnection();
        List<StuSub> bySuid = stuSubDao.getBySuid(suid, connection);
        JDBCUtil.closeConnection(connection);
        return bySuid;
    }

    @Override
    public StuSub getBySidAndSuid(Integer sid, Integer suid) {
        Connection connection = JDBCUtil.getConnection();
        StuSub StuSub = stuSubDao.getBySidAndSuid(sid, suid, connection);
        JDBCUtil.closeConnection(connection);
        return StuSub;
    }

    @Override
    public int deleteBySidAndSuid(Integer sid, Integer suid) {
        Connection connection = JDBCUtil.getConnection();
        int i = stuSubDao.deleteBySidAndSuid(sid, suid, connection);
        JDBCUtil.closeConnection(connection);
        return i;
    }

    @Override
    public int deleteSelect(List<Integer> ids, Integer sid) {
        Connection connection = JDBCUtil.getConnection();
        int i = stuSubDao.deleteSelect(ids, sid, connection);
        JDBCUtil.closeConnection(connection);
        return i;
    }
}
